import { Body, Controller, Delete, Get, Post } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { Permission, RequireLogin } from 'src/decorator/custom.decorator';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get()
  initData() {
    return this.userService.initData();
  }

  @Post('login')
  login(@Body() createUserDto: CreateUserDto) {
    return this.userService.login(createUserDto);
  }

  @RequireLogin()
  @Get('add')
  add(): string {
    return 'add';
  }

  @RequireLogin()
  @Permission('query', 'del')
  @Delete('del')
  delete(): string {
    return 'delete';
  }
}
